﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Resto.CostControl.Core.Domain.Model;
using Resto.CostControl.Core.Facade.MaterialModule.DataTransferObject;
using Resto.CostControl.Core.Cache;

namespace Resto.CostControl.Core.Facade.DishDeliveryModule.DataTransferObject
{
    /// <summary>
    /// 菜肴发货单的项DTO
    /// </summary>
    [Serializable]
    public class DishDeliveryItemDTO
    {
        #region 构造函数

        public DishDeliveryItemDTO() { }

        internal DishDeliveryItemDTO(DishDeliveryItem item)
        {
            this.ID = item.ID;
            this.DeliveryCount = item.DeliveryCount;
            this.SignCount = item.SignCount;
            this.MaterialId = item.MaterialID;

            this.Material = MaterialDTOCache.Get(item.MaterialID);
        }

        #endregion

        #region 基本属性

        public string ID { get; set; }
        
        /// <summary>
        /// 品名Id
        /// </summary>
        public string MaterialId { get; set; }

        public MaterialDTO Material { get; protected set; }

        /// <summary>
        /// 发货数
        /// </summary>
        public decimal? DeliveryCount { get; set; }

        /// <summary>
        /// 签收数
        /// </summary>
        public decimal? SignCount { get; set; }

        #endregion

        #region 方法

        internal DishDeliveryItem ToDishDeliveryItem()
        {
            DishDeliveryItem item = new DishDeliveryItem();
            CopyToDishDeliveryItem(item);
            return item;
        }

        internal void CopyToDishDeliveryItem(DishDeliveryItem item)
        {
            item.MaterialID = this.MaterialId;
            item.DeliveryCount = this.DeliveryCount;           
            item.SignCount = this.SignCount;
            
        }

        #endregion
    }
}
